/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.mc.sdk.usercenter.common.enums;

import cn.hallele.infrastructure.data.converter.EnumConverter;
import cn.hallele.infrastructure.util.EnumUtil;
import lombok.Getter;

/**
 * hallele_mc_sdk
 *
 * @author anle5
 * @since 2024/11/12 22:55
 */
@Getter
public enum DeptStatusEnum implements EnumConverter<String> {
    /**
     * 启用
     */
    OPEN("0"),

    /**
     * 禁用
     */
    CLOSED("1");

    /**
     * 内部标识
     */
    private final String code;

    DeptStatusEnum(String code) {
        this.code = code;
    }

    /**
     * 转换成实体字段值
     *
     * @param columValue 表字段里面的值
     * @return name
     */
    @Override
    public EnumConverter<String> convertToEntityAttribute(String columValue) {
        return EnumUtil.getBy((EnumUtil.HalFunction<DeptStatusEnum, String>) param -> param.code, columValue);
    }

    /**
     * 转换成表字段值
     *
     * @return 表字段里面的值
     */
    @Override
    public String convertToDatabaseColumn() {
        return this.code;
    }

    /**
     * DeptStatusEnum
     *
     * @param columValue code
     * @return DeptStatusEnum
     */
    public static DeptStatusEnum valueOfCode(String columValue) {
        return EnumUtil.getBy((EnumUtil.HalFunction<DeptStatusEnum, String>) param -> param.code, columValue);
    }
}
